various safety and correctness improvements#301
Merged
Merged
Conversation
Require Header implementors to report the full structure size and derive payload_len() from it. Validate undersized reports before building DynSizedStructure values, and use the reported total size for tag iteration as well. This makes the reported size the single source of truth. The old shape spread the invariant across payload_len(), total_size(), and per-type assertions, which was easy to drift out of sync. With one authoritative value, the parsing code can validate once and reuse the same size for construction, iteration, and downstream casts. Update the concrete header types in multiboot2 and multiboot2-header to the new contract, and add a regression test for a reported size that is smaller than the fixed header. Breaking: Header implementors now provide total_size() instead of payload_len(). multiboot2*: simplify MaybeDynSize trait for implementors
Add precise SAFETY comments end enable clippy enforcement for safety comments.
Make the RSDP constructors fill in the checksum fields themselves so callers do not have to pass them in, and keep the builder tests matched to that API change. Validation now uses fixed-size slices for RSDP v1 and rejects bogus v2 lengths before slicing, which removes the previous out-of-bounds read risk from checksum validation.
1.85 and 1.86 have a bug in clippy that let CI fail, although the code is valid.
This reverts commit dcb05ad.
This bug exists at least in clippy 1.85 and 1.86. 1.87 is fine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.